/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package eeep.controles;

import eeep.dao.BoletinDAO;
import eeep.dao.MateriaDAO;
import eeep.dao.PessoaDAO;
import eeep.entidades.Boletin;
import eeep.entidades.Materia;
import eeep.excecoes.PJCException;
import eeep.excecoes.PNEException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Junior
 */
public class BoletinControle {
    BoletinDAO bDao = new BoletinDAO();
    MateriaDAO mDao = new MateriaDAO();
    
    public void salvarBoletin(ArrayList<Boletin> boletins) throws PJCException{
        Boletin boletin;
        int i=0;
        for(Materia materia : mDao.getMaterias()) {
            try {
                this.buscarBoletin(boletins.get(i));
                throw new PJCException();
            } catch (PNEException ex) {
                bDao.salvarBoletin(boletins.get(i));
                i++;
            }
                       
        }
    }
    public Boletin buscarBoletin(Boletin boletin) throws PNEException{
        if(bDao.getBoletinPorMateiraPessoa(boletin)!=null)
            return bDao.getBoletinPorMateiraPessoa(boletin);
        else
            throw new PNEException();
    }
    public void atualizarBoletin(Boletin boletin)throws PNEException{
        this.buscarBoletin(boletin);
        bDao.atualizarBoletin(boletin);
    }
    public void removerBoletin(Boletin boletin)throws PNEException{
        this.buscarBoletin(boletin);
        bDao.deleteBoletin(boletin);
    }
    
}
